package com.aos.erp.generator.mapper;

import com.aos.erp.common.dao.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 代码生成器
 */
public interface GeneratorMapper extends SuperMapper {

    @Select("<script> select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables " +
            " where table_schema = (select database())  " +
            " <if test=\"tableName !=null and tableName != '' \"> and tableName like concat('%', #{tableName}, '%')  </if> " +
            " order by table_name" +
            "</script>")
        //IPage<Map<String, Object>> queryList(Page page, @Param("tableName") String tableName);
    List<Map<String, Object>> queryList(@Param("tableName") String tableName);


    @Select("<script> select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables " +
            " where table_schema = (select database())  " +
            " <if test=\"tableName !=null and tableName != '' \"> and table_name like concat('%', #{tableName}, '%')  </if> " +
            " order by table_name" +
            "</script>")
        //IPage<Map<String, Object>> queryList(Page page, @Param("tableName") String tableName);
    List<Map<String, Object>> selectPage(IPage page, @Param("tableName") String tableName);

    @Select("select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables  " +
            " where table_schema = (select database())  and table_name = #{tableName} ")
    Map<String, String> queryTable(String tableName);

    @Select(" select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns  " +
            " where table_name = #{tableName} and table_schema = (select database()) order by ordinal_position ")
    List<Map<String, String>> queryColumns(String tableName);
}
